package org.piggy.core.context;

import io.netty.channel.ChannelHandlerContext;
import org.piggy.common.rule.Rule;
import org.piggy.core.reponse.GatewayResponse;
import org.piggy.core.request.GatewayRequest;
import java.util.function.Consumer;

public interface Context {
    int RUNNING = 0;

    int WRITTEN = 1;

    int COMPLETED = 2;

    int TERMINATED = -1;

    void running();

    void written();

    void completed();

    void terminated();

    boolean isRunning();

    boolean isWritten();

    boolean isCompleted();

    boolean isTerminated();

    boolean isKeepAlive();

    String getProtocol();

    GatewayRequest getGatewayRequest();

    GatewayResponse getGatewayResponse();

    Rule getRule();

    Throwable getThrowable();

    ChannelHandlerContext getChannelHandlerContext();

    Object getAttribute(String key);

    void setAttribute(String key, Object obj);

    void releaseRequest();

    void setTerminatedCallBack(Consumer<Context> consumer);

    void invokeTerminatedCallBack();
}
